(0) Obligation:

Runtime Complexity TRS:
The TRS R consists of the following rules:

isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0) → s(0)
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0)

Rewrite Strategy: INNERMOST

(1) RenamingProof (EQUIVALENT transformation)

Renamed function symbols to avoid clashes with predefined symbol.

(2) Obligation:

Runtime Complexity Relative TRS:
The TRS R consists of the following rules:

isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

S is empty.
Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Innermost TRS:
Rules:
isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

Types:
isEmpty :: empty:node → true:false
empty :: empty:node
true :: true:false
node :: empty:node → empty:node → empty:node
false :: true:false
left :: empty:node → empty:node
right :: empty:node → empty:node
inc :: 0':s → 0':s
0' :: 0':s
s :: 0':s → 0':s
count :: empty:node → 0':s → 0':s
if :: true:false → true:false → empty:node → empty:node → 0':s → 0':s → 0':s
nrOfNodes :: empty:node → 0':s
hole_true:false1_0 :: true:false
hole_empty:node2_0 :: empty:node
hole_0':s3_0 :: 0':s
gen_empty:node4_0 :: Nat → empty:node
gen_0':s5_0 :: Nat → 0':s

(5) OrderProof (LOWER BOUND(ID) transformation)

Heuristically decided to analyse the following defined symbols:
inc, count

They will be analysed ascendingly in the following order:
inc < count

(6) Obligation:

Innermost TRS:
Rules:
isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

Types:
isEmpty :: empty:node → true:false
empty :: empty:node
true :: true:false
node :: empty:node → empty:node → empty:node
false :: true:false
left :: empty:node → empty:node
right :: empty:node → empty:node
inc :: 0':s → 0':s
0' :: 0':s
s :: 0':s → 0':s
count :: empty:node → 0':s → 0':s
if :: true:false → true:false → empty:node → empty:node → 0':s → 0':s → 0':s
nrOfNodes :: empty:node → 0':s
hole_true:false1_0 :: true:false
hole_empty:node2_0 :: empty:node
hole_0':s3_0 :: 0':s
gen_empty:node4_0 :: Nat → empty:node
gen_0':s5_0 :: Nat → 0':s

Generator Equations:
gen_empty:node4_0(0) ⇔ empty
gen_empty:node4_0(+(x, 1)) ⇔ node(empty, gen_empty:node4_0(x))
gen_0':s5_0(0) ⇔ 0'
gen_0':s5_0(+(x, 1)) ⇔ s(gen_0':s5_0(x))

The following defined symbols remain to be analysed:
inc, count

They will be analysed ascendingly in the following order:
inc < count

(7) RewriteLemmaProof (LOWER BOUND(ID) transformation)

Proved the following rewrite lemma:
inc(gen_0':s5_0(n7_0)) → gen_0':s5_0(+(1, n7_0)), rt ∈ Ω(1 + n70)

Induction Base:
inc(gen_0':s5_0(0)) →RΩ(1)
s(0')

Induction Step:
inc(gen_0':s5_0(+(n7_0, 1))) →RΩ(1)
s(inc(gen_0':s5_0(n7_0))) →IH
s(gen_0':s5_0(+(1, c8_0)))

We have rt ∈ Ω(n1) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n).

(8) Complex Obligation (BEST)

(9) Obligation:

Innermost TRS:
Rules:
isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

Types:
isEmpty :: empty:node → true:false
empty :: empty:node
true :: true:false
node :: empty:node → empty:node → empty:node
false :: true:false
left :: empty:node → empty:node
right :: empty:node → empty:node
inc :: 0':s → 0':s
0' :: 0':s
s :: 0':s → 0':s
count :: empty:node → 0':s → 0':s
if :: true:false → true:false → empty:node → empty:node → 0':s → 0':s → 0':s
nrOfNodes :: empty:node → 0':s
hole_true:false1_0 :: true:false
hole_empty:node2_0 :: empty:node
hole_0':s3_0 :: 0':s
gen_empty:node4_0 :: Nat → empty:node
gen_0':s5_0 :: Nat → 0':s

Lemmas:
inc(gen_0':s5_0(n7_0)) → gen_0':s5_0(+(1, n7_0)), rt ∈ Ω(1 + n70)

Generator Equations:
gen_empty:node4_0(0) ⇔ empty
gen_empty:node4_0(+(x, 1)) ⇔ node(empty, gen_empty:node4_0(x))
gen_0':s5_0(0) ⇔ 0'
gen_0':s5_0(+(x, 1)) ⇔ s(gen_0':s5_0(x))

The following defined symbols remain to be analysed:
count

(10) RewriteLemmaProof (LOWER BOUND(ID) transformation)

Proved the following rewrite lemma:
count(gen_empty:node4_0(n291_0), gen_0':s5_0(b)) → gen_0':s5_0(+(n291_0, b)), rt ∈ Ω(1 + b + b·n2910 + n2910)

Induction Base:
count(gen_empty:node4_0(0), gen_0':s5_0(b)) →RΩ(1)
if(isEmpty(gen_empty:node4_0(0)), isEmpty(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)), node(left(left(gen_empty:node4_0(0))), node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, isEmpty(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)), node(left(left(gen_empty:node4_0(0))), node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, isEmpty(empty), right(gen_empty:node4_0(0)), node(left(left(gen_empty:node4_0(0))), node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, right(gen_empty:node4_0(0)), node(left(left(gen_empty:node4_0(0))), node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, empty, node(left(left(gen_empty:node4_0(0))), node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, empty, node(left(empty), node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, empty, node(empty, node(right(left(gen_empty:node4_0(0))), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, empty, node(empty, node(right(empty), right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, empty, node(empty, node(empty, right(gen_empty:node4_0(0)))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(true, true, empty, node(empty, node(empty, empty)), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →LΩ(1 + b)
if(true, true, empty, node(empty, node(empty, empty)), gen_0':s5_0(b), gen_0':s5_0(+(1, b))) →RΩ(1)
gen_0':s5_0(b)

Induction Step:
count(gen_empty:node4_0(+(n291_0, 1)), gen_0':s5_0(b)) →RΩ(1)
if(isEmpty(gen_empty:node4_0(+(n291_0, 1))), isEmpty(left(gen_empty:node4_0(+(n291_0, 1)))), right(gen_empty:node4_0(+(n291_0, 1))), node(left(left(gen_empty:node4_0(+(n291_0, 1)))), node(right(left(gen_empty:node4_0(+(n291_0, 1)))), right(gen_empty:node4_0(+(n291_0, 1))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, isEmpty(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))), node(left(left(gen_empty:node4_0(+(1, n291_0)))), node(right(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, isEmpty(empty), right(gen_empty:node4_0(+(1, n291_0))), node(left(left(gen_empty:node4_0(+(1, n291_0)))), node(right(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, right(gen_empty:node4_0(+(1, n291_0))), node(left(left(gen_empty:node4_0(+(1, n291_0)))), node(right(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, gen_empty:node4_0(n291_0), node(left(left(gen_empty:node4_0(+(1, n291_0)))), node(right(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, gen_empty:node4_0(n291_0), node(left(empty), node(right(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, gen_empty:node4_0(n291_0), node(empty, node(right(left(gen_empty:node4_0(+(1, n291_0)))), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, gen_empty:node4_0(n291_0), node(empty, node(right(empty), right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, gen_empty:node4_0(n291_0), node(empty, node(empty, right(gen_empty:node4_0(+(1, n291_0))))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →RΩ(1)
if(false, true, gen_empty:node4_0(n291_0), node(empty, node(empty, gen_empty:node4_0(n291_0))), gen_0':s5_0(b), inc(gen_0':s5_0(b))) →LΩ(1 + b)
if(false, true, gen_empty:node4_0(n291_0), node(empty, node(empty, gen_empty:node4_0(n291_0))), gen_0':s5_0(b), gen_0':s5_0(+(1, b))) →RΩ(1)
count(gen_empty:node4_0(n291_0), gen_0':s5_0(+(1, b))) →IH
gen_0':s5_0(+(+(1, b), c292_0))

We have rt ∈ Ω(n2) and sz ∈ O(n). Thus, we have ircR ∈ Ω(n2).

(11) Complex Obligation (BEST)

(12) Obligation:

Innermost TRS:
Rules:
isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

Types:
isEmpty :: empty:node → true:false
empty :: empty:node
true :: true:false
node :: empty:node → empty:node → empty:node
false :: true:false
left :: empty:node → empty:node
right :: empty:node → empty:node
inc :: 0':s → 0':s
0' :: 0':s
s :: 0':s → 0':s
count :: empty:node → 0':s → 0':s
if :: true:false → true:false → empty:node → empty:node → 0':s → 0':s → 0':s
nrOfNodes :: empty:node → 0':s
hole_true:false1_0 :: true:false
hole_empty:node2_0 :: empty:node
hole_0':s3_0 :: 0':s
gen_empty:node4_0 :: Nat → empty:node
gen_0':s5_0 :: Nat → 0':s

Lemmas:
inc(gen_0':s5_0(n7_0)) → gen_0':s5_0(+(1, n7_0)), rt ∈ Ω(1 + n70)
count(gen_empty:node4_0(n291_0), gen_0':s5_0(b)) → gen_0':s5_0(+(n291_0, b)), rt ∈ Ω(1 + b + b·n2910 + n2910)

Generator Equations:
gen_empty:node4_0(0) ⇔ empty
gen_empty:node4_0(+(x, 1)) ⇔ node(empty, gen_empty:node4_0(x))
gen_0':s5_0(0) ⇔ 0'
gen_0':s5_0(+(x, 1)) ⇔ s(gen_0':s5_0(x))

No more defined symbols left to analyse.

(13) LowerBoundsProof (EQUIVALENT transformation)

The lowerbound Ω(n2) was proven with the following lemma:
count(gen_empty:node4_0(n291_0), gen_0':s5_0(b)) → gen_0':s5_0(+(n291_0, b)), rt ∈ Ω(1 + b + b·n2910 + n2910)

(14) BOUNDS(n^2, INF)

(15) Obligation:

Innermost TRS:
Rules:
isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

Types:
isEmpty :: empty:node → true:false
empty :: empty:node
true :: true:false
node :: empty:node → empty:node → empty:node
false :: true:false
left :: empty:node → empty:node
right :: empty:node → empty:node
inc :: 0':s → 0':s
0' :: 0':s
s :: 0':s → 0':s
count :: empty:node → 0':s → 0':s
if :: true:false → true:false → empty:node → empty:node → 0':s → 0':s → 0':s
nrOfNodes :: empty:node → 0':s
hole_true:false1_0 :: true:false
hole_empty:node2_0 :: empty:node
hole_0':s3_0 :: 0':s
gen_empty:node4_0 :: Nat → empty:node
gen_0':s5_0 :: Nat → 0':s

Lemmas:
inc(gen_0':s5_0(n7_0)) → gen_0':s5_0(+(1, n7_0)), rt ∈ Ω(1 + n70)
count(gen_empty:node4_0(n291_0), gen_0':s5_0(b)) → gen_0':s5_0(+(n291_0, b)), rt ∈ Ω(1 + b + b·n2910 + n2910)

Generator Equations:
gen_empty:node4_0(0) ⇔ empty
gen_empty:node4_0(+(x, 1)) ⇔ node(empty, gen_empty:node4_0(x))
gen_0':s5_0(0) ⇔ 0'
gen_0':s5_0(+(x, 1)) ⇔ s(gen_0':s5_0(x))

No more defined symbols left to analyse.

(16) LowerBoundsProof (EQUIVALENT transformation)

The lowerbound Ω(n2) was proven with the following lemma:
count(gen_empty:node4_0(n291_0), gen_0':s5_0(b)) → gen_0':s5_0(+(n291_0, b)), rt ∈ Ω(1 + b + b·n2910 + n2910)

(17) BOUNDS(n^2, INF)

(18) Obligation:

Innermost TRS:
Rules:
isEmpty(empty) → true
isEmpty(node(l, r)) → false
left(empty) → empty
left(node(l, r)) → l
right(empty) → empty
right(node(l, r)) → r
inc(0') → s(0')
inc(s(x)) → s(inc(x))
count(n, x) → if(isEmpty(n), isEmpty(left(n)), right(n), node(left(left(n)), node(right(left(n)), right(n))), x, inc(x))
if(true, b, n, m, x, y) → x
if(false, false, n, m, x, y) → count(m, x)
if(false, true, n, m, x, y) → count(n, y)
nrOfNodes(n) → count(n, 0')

Types:
isEmpty :: empty:node → true:false
empty :: empty:node
true :: true:false
node :: empty:node → empty:node → empty:node
false :: true:false
left :: empty:node → empty:node
right :: empty:node → empty:node
inc :: 0':s → 0':s
0' :: 0':s
s :: 0':s → 0':s
count :: empty:node → 0':s → 0':s
if :: true:false → true:false → empty:node → empty:node → 0':s → 0':s → 0':s
nrOfNodes :: empty:node → 0':s
hole_true:false1_0 :: true:false
hole_empty:node2_0 :: empty:node
hole_0':s3_0 :: 0':s
gen_empty:node4_0 :: Nat → empty:node
gen_0':s5_0 :: Nat → 0':s

Lemmas:
inc(gen_0':s5_0(n7_0)) → gen_0':s5_0(+(1, n7_0)), rt ∈ Ω(1 + n70)

Generator Equations:
gen_empty:node4_0(0) ⇔ empty
gen_empty:node4_0(+(x, 1)) ⇔ node(empty, gen_empty:node4_0(x))
gen_0':s5_0(0) ⇔ 0'
gen_0':s5_0(+(x, 1)) ⇔ s(gen_0':s5_0(x))

No more defined symbols left to analyse.

(19) LowerBoundsProof (EQUIVALENT transformation)

The lowerbound Ω(n1) was proven with the following lemma:
inc(gen_0':s5_0(n7_0)) → gen_0':s5_0(+(1, n7_0)), rt ∈ Ω(1 + n70)

(20) BOUNDS(n^1, INF)